package vip.zhenzicheng.design_patterns.command;

import java.util.Map;
import java.util.Set;

/**
 * 具体的命令类
 *
 * @author zhenzicheng
 * @date 2022-05-26 18:40
 */
public class OrderCommand implements Command {

  // 持有接收者对象
  private final SeniorChef receiver;
  private final Order order;

  public OrderCommand(SeniorChef receiver, Order order) {
    this.receiver = receiver;
    this.order = order;
  }

  @Override
  public void execute() {
    System.out.println(order.getDiningTable() + "桌的订单：");
    Map<String, Integer> foodDir = order.getFoodDir();

    Set<String> keys = foodDir.keySet();
    for (String foodName : keys) {
      receiver.makeFood(foodName, foodDir.get(foodName));
    }

    System.out.println(order.getDiningTable() + "桌的饭准备完毕！！！");
  }
}
